package com.quanyan.ic.producer;

import com.quanyan.ic.constants.MQConstant;
import com.quanyan.ic.middleware.mq.rocketmq.producer.AbstractProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class PlaceOrderMessageProducer extends AbstractProducer {

    private static final Logger log = LoggerFactory.getLogger(PlaceOrderMessageProducer.class);

    @Value("${rocketmq.nameServer}")
    private String nameServerAddress;

    @PostConstruct
    public void start() {
        super.start();
    }

    public void syncSend(String msgId, byte[] body) {
        super.syncSend(MQConstant.IC_LIGHT_CONTROL_TOPIC, MQConstant.IC_LIGHT_CONTROL_TAG, 0, msgId, body);
    }

    @Override
    public String getProducerGroup() {
        return "group_place_ic_light_order_product";
    }

    @Override
    public String getNameServerAddress() {
        //192.168.30.100:9876;192.168.30.148:9876 beta环境
        //10.51.115.108:9876;10.51.115.30:9876 预发布环境
        //10.174.12.82:9876;10.45.150.231:9876 生产环境
//        return "192.168.30.100:9876;192.168.30.148:9876";
        return nameServerAddress;
    }

    @Override
    public String getInstanceName() {
        return MQConstant.IC_LIGHT_CONTROL_MQ_INSTANCE_NAME;
    }
}
